revision:
The "dir" attribute specifies the text-direction.
Syntax:
element.dir : returns the text direction
element.dir = ltr|rtl|auto" : sets the text direction
property value:
ltr : left-to-right text direction (default).
rtl : right-to-left text direction.
auto : let the browser figure out.
example
Click "try it" to change my text direction.
<div> <p id="par" style="font-size: 0.9vw;">Click "try it" to change my text direction.</p> <button onclick="firstFunction()">Try it</button> </div> <script> function firstFunction() { document.getElementById("par").dir = "rtl"; } </script>
My text direction is:
<div> <p>My text direction is:</p> <p id="prop"></p> </div> <script> var x = document.getElementById('DIV').dir; document.getElementById("prop").innerHTML = x; </script>